<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible"content="IE=8"><!--以IE8模式渲染-->
	<meta http-equiv="X-UA-Compatible"content="IE=7"><!--以IE7模式渲染-->
	<meta http-equiv="X-UA-Compatible"content="IE=9; IE=8; IE=7; IE=EDGE">
	<title>用户操作</title>
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/manage.css" >
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/easyui/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/easyui/themes/icon.css">
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/easyui/demo.css">

	<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/manage.css" >
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/role_add.css" >
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/js/jquery_validate/css/validationEngine.jquery.css" >
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/js/jquery.alert.v1.2/jquery.alert.css"/>
	<script type="text/javascript" src="__PUBLIC__/js/easyuiTab/jquery-1.4.4.min.js"></script>
	<script type="text/javascript" src="__PUBLIC__/js/jquery.alert.v1.2/jquery.alert.js"></script>  
	<script type="text/javascript" src="__PUBLIC__/js/ajax.js"></script>
	<script TYPE="text/javascript" src="__PUBLIC__/js/common.js"></script>
	<script type="text/javascript" src="__PUBLIC__/js/mydate.js"></script>
	<script TYPE="text/javascript" src="__PUBLIC__/js/jquery-1.8.0.min.js"></script>

	<script type="text/javascript" src="__PUBLIC__/easyui/jquery.min.js"></script>
	<script type="text/javascript" src="__PUBLIC__/easyui/jquery.easyui.min.js"></script>
	<style type="text/css">
		.input 
		{
			border: 1px solid #eaeaea;
			background-color: #6d654e;
			color: #fff;
			text-align: center;
			padding: 0px 10px -1px;
			border-radius: 4px;
		}
	</style>
	<script type="text/javascript">
		$(function() 
		{
			var json = '{$orderList_json}';
			var array = eval('('+json+')');
			$('#invest_table').datagrid({loadFilter:pagerFilter}).datagrid('loadData', array);
		});

		function orderSubmit() 
		{
			if (borrowNumValidate() & borrowNameValidate() & borrowCardNumValidate() & borrowMoneyValidate() & borrowPeriodValidate() & borrowDateValidate() & borrowTypeValidate()) 
			{
				$("#investForm").submit();
			}
		}

		function formatAction(value,row,index) 
		{
			var a = '<input type="button" value="删除" class="input" onclick="delData('+row.order_id+');">';
			return a;
		}

		function delData(order_id) 
		{
			var url = "../../invest/invest/invest_order_add_del";
			$.ajax({
				type: "POST",
				async: true,
				data: {"cancelData":order_id},
				url: url,
				success: function(d) 
				{
					// console.log(d);
					if (d == 1) 
					{
						window.location.reload();
					}
					else
					{
						alert('操作失败，请尝试重新操作或联系管理员！');
						window.history.back(); 
					}
				},
				error: function(e) 
				{
					alert(e);
				}
			});
		}

		//	借款编号验证
		function borrowNumValidate() 
		{
			var value=$("#borrowNum").val();
			var reg = new RegExp("^[0-9]*$");
			if(value==''||value==null) 
			{
				jAlert("借款编号不能为空！",'错误提示',null);
				return false;
			}
			else if(!reg.test(value)) 
			{
				jAlert("借款编号必须为数字！",'错误提示',null);
				return false;
			}
			else
			{
				return true;
			}
		}

		//	借款人验证
		function borrowNameValidate() 
		{
			var value=$("#borrowName").val();
			if(value==null||value=='') 
			{
				jAlert("借款人不能为空！",'错误提示',null);
				return false;
			}
			else
			{
				return true;
			}
		}

		//	身份证号验证
		function borrowCardNumValidate() 
		{
			var value=$("#borrowCardNum").val();
			if(value == null || value == '') 
			{
				jAlert("身份证号不能为空！",'错误提示',null);
				return false;
			}
			else
			{
				return true;
			}
		}

		//	借款金额验证
		function borrowMoneyValidate() 
		{
			var value=$("#borrowMoney").val();
			var reg = new RegExp("^[0-9]*$");
			if(value==null||value=='') 
			{
				jAlert("借款金额不能为空！",'错误提示',null);
				return false;
			}
			else if(!reg.test(value)) 
			{
				jAlert("借款金额必须为数字！",'错误提示',null);
				return false;
			}
			else
			{
				return true;
			}
		}

		//	借款期数验证
		function borrowPeriodValidate() 
		{
			var value=$("#borrowPeriod").val();
			var reg = new RegExp("^[1-9]*$");
			if(value==null||value=='') 
			{
				jAlert("借款期数不能为空！",'错误提示',null);
				return false;
			}
			else if(!reg.test(value)) 
			{
				jAlert("借款期数必须为数字！",'错误提示',null);
				return false;
			}
			else
			{
				return true;
			}
		}

		//	借款时间验证
		function borrowDateValidate() 
		{
			var value=$("#borrowDate").val();
			if(value==null||value=='') 
			{
				jAlert("借款时间不能为空！",'错误提示',null);
				return false;
			}
			else
			{
				return true;
			}
		}

		//	服务类型验证
		function borrowTypeValidate() 
		{
			var value=$("#borrowType").val();
			if(value==null||value=='') 
			{
				jAlert("服务类型不能为空！",'错误提示',null);
				return false;
			}
			else
			{
				return true;
			}
		}

        // function success(invest_id){
        //     jAlert('新增订单成功！','新增提示',function(e){
        //         window.location.href="invest_order_add.php?invest_id="+invest_id;
        //         exit;
        //     });
        // }

        // function error(){
        //     jAlert('新增订单失败！请与管理员联系！','新增提示',null);
        // }

        
    </script>
</head>
<body>
	<div class="contentPage">
		<h1>新增线下订单</h1>
		<form action="../../invest/invest/invest_order_add_submit" method="post" id="investForm" enctype="multipart/form-data">
			<input type="hidden" id="investId" name="invest_id" value="<?php echo $data_array['invest_id']; ?>">
			<table class="addForm">
				<tr>
					<th><span>*</span>借款编号：</th>
					<td>
						<input type="text" name="invest_borrowNum" id="borrowNum" class="validate[required]">
						<span id="typeSpan"> </span>
						<span id="borrowNumSpan"></span>
					</td>
				</tr>

				<tr>
					<th><span>*</span>所属项目：</th>
					<td>
						<input type="text" name="invest_title" readonly class="validate[required]" value="<?php echo $data_array['invest_title']; ?>">
						<span id="typeSpan"> </span>
					</td>
				</tr>

				<tr>
					<th><span>*</span>借款人姓名：</th>
					<td>
						<input type="text" name="invest_borrowName" id="borrowName" class="validate[required]">
						<span id="typeSpan"> </span>
					</td>
				</tr>

				<tr>
					<th><span>*</span>借款人身份证：</th>
					<td>
						<input type="text" name="invest_borrowCardNum" id="borrowCardNum" class="validate[required]">
						<span id="typeSpan"> </span>
					</td>
				</tr>

				<tr>
					<th><span>*</span>借款金额：</th>
					<td>
						<input type="text" name="invest_borrowMoney" id="borrowMoney" class="validate[required]">
						<span id="typeSpan"> </span>
					</td>
				</tr>

				<tr>
					<th><span>*</span>借款期数：</th>
					<td>
						<input type="text" name="invest_borrowPeriod" id="borrowPeriod" class="validate[required]">
						<span id="typeSpan"> </span>
					</td>
				</tr>

				<tr>
					<th><span>*</span>借款时间：</th>
					<td>
						<input type="text" name="invest_borrowDate" id="borrowDate" onfocus="MyCalendar.SetDate(this)">
						<span id="typeSpan"> </span>
					</td>
				</tr>

				<tr>
					<th><span>*</span>服务类型：</th>
					<td>
						<input type="text" name="invest_borrowType" id="borrowType" class="validate[required]">
						<span id="typeSpan"> </span>
					</td>
				</tr>

				<tr>
					<td colspan="2" class="addButton">
						<input type="hidden" id="loadNameFlag">
						<input type="button" value="保存" class="save" onclick="orderSubmit();">
						<input type="reset" value="重置" class="clear">
					</td>
				</tr>
			</table>
		</form><br/>
		<HR width="100%" color=black /><br/>

		<!-- <div>
			<h1 style="float: left">订单列表</h1>
		</div> -->
		<div class="invest_table">
			<table id="invest_table" title="订单列表" style="width:100%;height:auto" 
				data-options="
					rownumbers:true,
					singleSelect:true,
					autoRowHeight:false,
					pagination:true,
					pageSize:10
				"
			>
				<thead>
					<tr>
						<th field="order_num" width="10%" align="center">订单编号</th>
						<th field="invest_title" width="15%" align="center">所属项目</th>
						<th field="order_borrowname" width="8%" align="center">借款人</th>
						<th field="order_cardnum" width="17%" align="center">身份证号</th>
						<th field="order_borrowmoney" width="8%" align="center">借款金额</th>
						<th field="order_period" width="10%" align="center">借款周期</th>
						<th field="order_borrowtime" width="10%" align="center">借款时间</th>
						<th field="order_servicetype" width="15%" align="center">服务类型</th>
						<th field="action" width="6%" align="center" formatter="formatAction">操作</th>
					</tr>
				</thead>
			</table>
		</div>
		<!-- <div id="invest_list"></div> -->
	</div>
</body>
</html>

